#ifndef PARSER_DELETE_H
#define PARSER_DELETE_H

#include "ParserBase.h"

/**
 * This is the handler for delete commands.
 * 
 * Developers should note that there are commands here which may be interpreted
 * in several ways - for example the command "delete done" may refer to the deletion
 * of all "done" tasks. However, it could also mean for the program to delete the 
 * task containing "done".
 *
 * In the above case - the more precise syntax will be chosen over the more relaxed
 * version - ie. delete done will delete all "done" tasks
 @author Ling Chun Kai
*/

class ParserDelete : public ParserBase {
public:
	ParserDelete(ParserBase* _nextParser);
private:
	enum {INSTRUCTION_POS = 1, ARGUMENTS_POS, NUM_MAJOR_SEGMENTS};

	// The following are regex constants used for parsing
	static const string regexInstructionAndArguments;

	// Valid variants of delete instructions
	static const string regexInstructionDelete;

	static const string regexArgumentDeleteTaskID;
	static const string regexArgumentDeleteSearchTerm;
	static const string regexArgumentDeleteDone;

	// Argument positions
	static const int ARGUMENT_POS_DELETE_SEARCHTERM = 1;
	static const int ARGUMENT_POS_DELETE_DONE = 1;
	static const int ARGUMENT_POS_DELETE_TASKID = 1;

	bool tryParse(string userCommand, PARSED_COMMAND& parsedCommand);

	bool getInstructionAndArguments(const string& userCommand, 
										string& instruction, 
										string& arguments);

	// This method checks that the instruction is of the type 'delete'
	bool checkInstruction(const string& instruction);

	// This method finds out what kind of "delete" command the user entered
	CommandType categorizeDeleteCommand(const string& arguments, smatch& matchingArguments);

	void parseDelete(PARSED_COMMAND& parsedCommand,
				  const string& arguments);

	// Methods used to fill the PARSED_COMMAND class
	void makeParsedCommandDeleteSearchTerm(PARSED_COMMAND& parsedCommand, 
										  smatch& matchingArguments);
	void makeParsedCommandDeleteTaskID(PARSED_COMMAND& parsedCommand, 
										  smatch& matchingArguments);
	void makeParsedCommandDeleteDone(PARSED_COMMAND& parsedCommand, 
									   smatch& matchingArguments);
};

#endif